package com.chenliang.version.biz;

import com.chenliang.version.config.ApiVersion;
import com.chenliang.version.entry.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: version_controller
 * @description:
 * @author: liangchen23
 * @create: 2022-03-15 14:31
 */
@RestController
@RequestMapping("api/{v}/user")
public class UserBiz {

    @GetMapping("/get")
    public User getUser() {
        return User.builder().age(18).name("pdai, default").build();
    }

    @ApiVersion("1.0.0")
    @GetMapping("/get")
    public User getUserV1() {
        return User.builder().age(18).name("pdai, v1.0.0").build();
    }

    @ApiVersion("1.1.0")
    @GetMapping("/get")
    public User getUserV11() {
        return User.builder().age(19).name("pdai, v1.1.0").build();
    }

    @ApiVersion("1.1.2")
    @GetMapping("/get")
    public User getUserV112() {
        return User.builder().age(19).name("pdai2, v1.1.2").build();
    }
}
